/*
 *  main.c
 *
 *  $Id: main.c 18 2009-08-22 01:08:08Z nramsbottom $	
 *
 */

#include <stdio.h>

#include "game.h"
#include "display.h"
#include "log.h"
#include "language.h"

#define DEFAULT_LANGUAGE	"en"

// TODO: Need to be able to enable debugging from command line
static char* debug_log = "./tictactoe_debug.txt";

int main (int argc, const char * argv[]) {

	// try and open debug log. if it fails, proceed anyway
	/*if (!log_open(debug_log))
		fprintf(stderr, "Warning: Unable to open debugging output file.\n");
	*/
	
	// TODO: Should accept a command line argument to allow localised messages.
	int languageid = language_findidbycode(DEFAULT_LANGUAGE);
	if (!languageid) {
		fprintf(stderr, "Warning: Unable to locate localised strings for %s. Using default.\n");
		languageid = LANG_DEFAULT;
	}
	
	language_setcurrent(languageid);
	
	display_startup();
	game_run();
	display_shutdown();
	
	// close/cleanup logging 
	log_close();
	
	return 0;
}
